import {createStore} from "redux"
let data ={
    list:[],//首页数据
    data:[

    ]//收货数据
}

 let reducer = (state=data,action)=>{
     state=JSON.parse(JSON.stringify(state))
     switch(action.type)
     {
        case "startPropo":
        state.list = action.obj.data
        state.data = action.obj.mocks
        console.log(action.obj)
            return state;
        case "addStop":
            state.data.push(action.obj)
            console.log(state.data)
            return state;
        case "remove":
            let fin =  state.data.findIndex((item,index)=>item.name===action.obj)
            console.log(fin)
            if(fin!== -1){
                state.data.splice(fin,1)
            }
            return state;
        case "addset":
                let find =  state.data.findIndex((item,index)=>item.name===action.name)
                if(find!==-1){
                    state.data[find] = action.obj
                }
                console.log(state.data)
            return state;
        
        default:
            return state;
     }
 }

 let store = createStore(reducer)

export default store